//
//  Head.m
//  PTravel
//
//  Created by dllo on 15/11/22.
//  Copyright © 2015年 李涵. All rights reserved.
//

#import "Head.h"

@implementation Head

- (void)dealloc
{
    [_answer release];
    [_company release];
    [_answerImage release];
    [_companyImage release];
    [_answerLabel release];
    [_answerNum release];
    [_companyLabel release];
    [_companyNum release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changColor) name:@"night" object:nil];
        [self createSubViews];
    }
    return self;
}

- (void)changColor
{
    self.answerLabel.textColor = TEXTCOLOR;
    self.companyLabel.textColor = TEXTCOLOR;
}
- (void)createSubViews
{
    self.answer = [UIButton buttonWithType:UIButtonTypeCustom];
    self.answer.frame = CGRectMake(0, 0, BOUNDS.size.width/2, 55);
    [self.contentView addSubview:self.answer];
    
    self.answerImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 40, 40)];
    self.answerImage.image = [UIImage imageNamed:@"iconfont-wenda.png"];
    self.answerImage.backgroundColor = [UIColor colorWithRed:0.380 green:1.000 blue:0.902 alpha:1.000];
    [self.answer addSubview:self.answerImage];
    [_answerImage release];
    
    self.answerLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.answerImage.frame.origin.x+self.answerImage.frame.size.width+10, self.answerImage.frame.origin.y, 100, 20)];
//    NSString *string = @"问答";
//    NSUInteger len = [string length];
//    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:string];
//    [str addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, len)];
//    [self.answerLabel setAttributedText:str];
    self.answerLabel.text = @"问答";
    self.answerLabel.textColor = TEXTCOLOR;
    [self.answer addSubview:self.answerLabel];
    [_answerLabel release];
    
    self.answerNum = [[UILabel alloc] initWithFrame:CGRectMake(self.answerLabel.frame.origin.x, self.answerLabel.frame.origin.y+self.answerLabel.frame.size.height, 70, 30)];
    self.answerNum.font = [UIFont systemFontOfSize:10];
    [self.answer addSubview:self.answerNum];
    [_answerNum release];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/2, self.answerLabel.frame.origin.y, 1, 36)];
    line.backgroundColor = [UIColor colorWithWhite:0.574 alpha:1.000];
    [self addSubview:line];
    
    self.company = [UIButton buttonWithType:UIButtonTypeCustom];
    self.company.frame = CGRectMake(BOUNDS.size.width/2, 0, BOUNDS.size.width/2, 55);
    [self.contentView addSubview:self.company];

    self.companyImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 40, 40)];
    self.companyImage.image = [UIImage imageNamed:@"iconfont-tongban.png"];
    self.companyImage.backgroundColor = [UIColor colorWithRed:0.156 green:1.000 blue:0.057 alpha:1.000];
    [self.company addSubview:self.companyImage];
    [_companyImage release];
    
    self.companyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.companyImage.frame.origin.x+self.companyImage.frame.size.width+10, self.companyImage.frame.origin.y, 100, 20)];
    self.companyLabel.text = @"结伴";
    self.companyLabel.textColor = TEXTCOLOR;
    [self.company addSubview:self.companyLabel];
    [_companyLabel release];
    
    self.companyNum = [[UILabel alloc] initWithFrame:CGRectMake(self.companyLabel.frame.origin.x, self.companyLabel.frame.origin.y+self.companyLabel.frame.size.height, 70, 30)];
    self.companyNum.font = [UIFont systemFontOfSize:10];
    [self.company addSubview:self.companyNum];
    [_companyLabel release];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
